package com.rockcent.mall.lib.repository;

import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.IntegrationCouponWallet;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;

/**
 * Created by zhangjh on 2016/12/14.
 */
@Repository
public interface IntegrationCouponWalletRepository extends JpaRepository<IntegrationCouponWallet, Long>, JpaSpecificationExecutor, IntegrationCouponWalletRepositoryCustom {

    /**
     * @param exchangeNum
     * @param receiveNum
     * @param useNum
     * @return
     */
    IntegrationCouponWallet findByExchangeNumAndReceiveNumAndUseNum(long exchangeNum, long receiveNum, long useNum);

    /**
     * @param exchangeCode
     * @param exchangeNum
     * @param receiveNum
     * @param useNum
     * @return
     */
    IntegrationCouponWallet findByExchangeCodeAndExchangeNumAndReceiveNumAndUseNum(String exchangeCode, long exchangeNum, long receiveNum, long useNum);

    /**
     * @param id
     * @param customerId
     * @param exchangeNum
     * @param receiveNum
     * @param useNum
     * @return
     */
    IntegrationCouponWallet findByIdAndCustomerIdAndExchangeNumAndReceiveNumAndUseNum(Long id, Long customerId, long exchangeNum, long receiveNum, long useNum);

    /**
     * @param customerId
     * @param exchangeNum
     * @param receiveNum
     * @param useNum
     * @return
     */
    IntegrationCouponWallet findTop1ByCustomerIdAndExchangeNumAndReceiveNumAndUseNum(Long customerId, long exchangeNum, long receiveNum, long useNum);

    /**
     * @param exchangeCode
     * @param channelId
     * @param no
     * @param l
     * @return
     */
    IntegrationCouponWallet findTop1ByExchangeCodeAndIntegrationChannelIdAndIsDeleteAndExchangeNum(String exchangeCode, long channelId, Whether no, long l);

    /**
     * @param id
     * @param integrationChannelId
     * @param no
     * @param exchangeNum
     * @return
     */
    IntegrationCouponWallet findTop1ByCouponIdAndIntegrationChannelIdAndIsDeleteAndExchangeNum(Long id, Long integrationChannelId, Whether no, long exchangeNum);


    /**
     * @param faceVal
     * @param integrationChannelId
     * @param no
     * @param exchangenum
     * @return
     */
    IntegrationCouponWallet findTop1ByFaceValueAndIntegrationChannelIdAndIsDeleteAndExchangeNum(BigDecimal faceVal, Long integrationChannelId, Whether no, long exchangenum);
}
